﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace NGinnBPM.Services.Wcf
{
    public class WcfNGinnServicesHost
    {
        public static ServiceHost ConfigureBasicNGinnServices(string srvUrl)
        {
            ServiceHost serviceHost = new ServiceHost(typeof(BasicNGinnServices), new Uri(srvUrl));
            serviceHost.AddServiceEndpoint(typeof(IBasicNGinnServices), new BasicHttpBinding(), "");
            var se = serviceHost.AddServiceEndpoint(typeof(IBasicNGinnServices), new WebHttpBinding(), "json");
            se.Behaviors.Add(new WebHttpBehavior { });

            System.ServiceModel.Description.ServiceMetadataBehavior smb = new System.ServiceModel.Description.ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            smb.HttpGetUrl = new Uri(srvUrl);
            serviceHost.Description.Behaviors.Add(smb);

            return serviceHost;
        }
    }
}
